package com.qf.index.gcrdo;


import cn.hutool.db.Entity;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang.StringUtils;

import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 工具类操作String类型的公共方法类
 */
public class StringUtil {

    private final static String regxpForHtml = "</([^>]*)>"; // 过滤所有以<开头以>结尾的标签

    private final static String regxpForHtml2 = "<([^>]*)>"; // 过滤所有以<开头以>结尾的标签

    /**
     * 判断字符串是否为空或null
     */
    public static boolean isEmpty(String cs) {
        return StringUtils.isEmpty(cs);
    }

    public static boolean isEmpty(Collection<?> collection) {
        return collection == null || collection.size() == 0;
    }

    /**
     * 判断字符串是否为空
     */
    public static boolean isNotNull(String str) {
        if (str != null && !str.equals("") && !str.equals("null") && !str.equals("[]") && !str.trim().equals("") && !str.toString().trim().equals("[]")) {
            return true;
        } else {
            return false;
        }
    }

//    public static Set<String> getMeshSet(String mesh, Set<String> mhSet) {
//        // 将mesh字符串转换成主题词集合（mhSet）和副主题词集合（shSet）两部分。
//        Set<String> shSet = new HashSet<>();
//        if (null != mesh && mesh.length() > 3) {
//            String[] split = mesh.split(";");
//            for (String mh : split) {
//                String[] mhs = mh.split("\\|");
//                mhSet.add(mhs[0]);
//                if (mhs.length == 2) {
//                    String[] shs = mhs[1].split("/");
//                    for (String sh : shs) {
//                        sh = sh.startsWith("*") ? sh.substring(1) : sh;
//                        shSet.add(sh);
//                    }
//                }
//            }
//        }
//        return shSet;
//    }


    // 取小数点后2位
    public static double takeFourDigits(Double d) {
        if (null == d || Double.isNaN(d) || Double.isInfinite(d)) {
            return 0.0;
        }
        BigDecimal bd = new BigDecimal(Double.toString(d));
        BigDecimal roundedBd = bd.setScale(2, RoundingMode.HALF_UP);
        return roundedBd.doubleValue();
    }

    // 对Map的值进行排序，此排序为最大的在前面，输入一个map，再返回一个排序后的新map，String, Integer类型，本排序增加了过滤功能，可以设置要前多少（len）个。
    public static Map<String, Integer> mapSortValueIntLen(Map<String, Integer> mapName) {
        Map<String, Integer> result = new LinkedHashMap<>();
        mapName.entrySet().stream().sorted(Map.Entry.<String, Integer>comparingByValue().reversed()).forEachOrdered(e -> result.put(e.getKey(), e.getValue()));
        return result;
    }


    public static Set<String> getEarly2023() {
        Set<String> set = new HashSet<>();
        set.add("JOURNAL OF ENVIRONMENTAL AND PUBLIC HEALTH");
        set.add("9424753");
        set.add("J CLIN LAB ANAL");
        set.add("WORLD JOURNAL OF CLINICAL CASES");
        set.add("101682385");
        set.add("101591609");
        set.add("JOURNAL OF CLINICAL LABORATORY ANALYSIS");
        set.add("TEXTILE RESEARCH JOURNAL");
        set.add("BUILDINGS BASEL");
        set.add("INT J CONTROL AUTOM");
        set.add("MACHINES");
        set.add("J BIOMATER TISSUE ENG");
        set.add("101512861");
        set.add("PSYCHIATRIA DANUBINA");
        set.add("ACTA MEDICA MEDITERRANEA");
        set.add("J STRUCT CHEM");
        set.add("ECON RES EKON ISTRAZ");
        set.add("FRONT ENVIRON SCI");
        set.add("FRONT EARTH SCI");
        set.add("FRONTIERS IN EARTH SCIENCE");
        set.add("9878794");
        set.add("MICROPROCESS MICROSYST");
        set.add("INT J CONTROL AUTOM SYST");
        set.add("EKON ISTRAZ");
        set.add("ENERGY REPORTS");
        set.add("INTERNATIONAL JOURNAL OF ELECTROCHEMICAL SCIENCE");
        set.add("FRONT SURG");
        set.add("101493030");
        set.add("PHARMAZIE");
        set.add("MATH PROBL ENG");
        set.add("INT J ELECTROCHEM SCI");
        set.add("WORLD J CLIN CASES");
        set.add("COMPUTATIONAL AND MATHEMATICAL METHODS IN MEDICINE");
        set.add("AMERICAN JOURNAL OF TRANSLATIONAL RESEARCH");
        set.add("101735833");
        set.add("JOURNAL OF INDUSTRIAL AND MANAGEMENT OPTIMIZATION");
        set.add("INORGANIC AND NANO METAL CHEMISTRY");
        set.add("AEROSPACE BASEL");
        set.add("INTERNATIONAL JOURNAL OF CONTROL AUTOMATION AND SYSTEMS");
        set.add("MOB INF SYST");
        set.add("BUILDINGS");
        set.add("COMPUT MATH METHOD M");
        set.add("101721978");
        set.add("FOOD SCIENCE AND TECHNOLOGY");
        set.add("FOOD SCI TECHNOL");
        set.add("FRONT EARTH SC SWITZ");
        set.add("MATHEMATICAL PROBLEMS IN ENGINEERING");
        set.add("J BIOMATER TISS ENG");
        set.add("JOURNAL OF BIOMATERIALS AND TISSUE ENGINEERING");
        set.add("TEXT RES J");
        set.add("MICROPROCESS MICROSY");
        set.add("ECONOMIC RESEARCH EKONOMSKA ISTRAZIVANJA");
        set.add("PSYCHIATR DANUB");
        set.add("FRONT ENV SCI SWITZ");
        set.add("J STRUCT CHEM+");
        set.add("MOBILE INFORMATION SYSTEMS");
        set.add("ENERGY REP");
        set.add("GEOFLUIDS");
        set.add("FOOD SCI TECH BRAZIL");
        set.add("101516361");
        set.add("AM J TRANSL RES");
        set.add("MICROPROCESSORS AND MICROSYSTEMS");
        set.add("PSYCHIAT DANUB");
        set.add("101748773");
        set.add("INORG NANO MET CHEM");
        set.add("J ENVIRON PUBLIC HEA");
        set.add("INT J ELECTROCHEM SC");
        set.add("101277751");
        set.add("101618806");
        set.add("J IND MANAG OPTIM");
        set.add("8801384");
        set.add("FRONTIERS IN SURGERY");
        set.add("JOURNAL OF STRUCTURAL CHEMISTRY");
        set.add("100954992");
        set.add("101645127");
        set.add("ACTA MEDICA MEDITERR");
        set.add("J ENVIRON PUBLIC HEALTH");
        set.add("AEROSPACE");
        set.add("FRONTIERS IN ENVIRONMENTAL SCIENCE");
        set.add("9800766");
        set.add("COMPUT MATH METHOD MED");
        set.add("101638676");
        return set;
    }

    public static Set<String> getEarly2021() {
        Set<String> set = new HashSet<>();
        set.add("AIMS MATHEMATICS");
        set.add("FRONT CELL DEV BIOL");
        set.add("101629355");
        set.add("SCI PROGRAMMING NETH");
        set.add("MOL THER NUCL ACIDS");
        set.add("VACCINES");
        set.add("101658402");
        set.add("MICROPROCESS MICROSYST");
        set.add("AGING US");
        set.add("PHARMAZIE");
        set.add("JOURNAL OF CELLULAR AND MOLECULAR MEDICINE");
        set.add("101778895");
        set.add("WORLD J CLIN CASES");
        set.add("J MATH");
        set.add("9891351");
        set.add("ANNALS OF PALLIATIVE MEDICINE");
        set.add("9888589");
        set.add("101586313");
        set.add("101676334");
        set.add("INT J GEN MED");
        set.add("SHOCK AND VIBRATION");
        set.add("AIMS MATH");
        set.add("SHOCK VIB");
        set.add("0346411");
        set.add("101475259");
        set.add("MITOCHONDRIAL DNA PART B RESOURCES");
        set.add("FRONTIERS IN CELL AND DEVELOPMENTAL BIOLOGY");
        set.add("101535920");
        set.add("JOURNAL OF MATHEMATICS");
        set.add("ONCOTARGETS THER");
        set.add("EXPERIMENTAL AND MOLECULAR PATHOLOGY");
        set.add("COMPLEXITY");
        set.add("FRONT MED LAUSANNE");
        set.add("BIOFACTORS");
        set.add("J PERS MED");
        set.add("SCI PROGRAM");
        set.add("9609063");
        set.add("HEALTHCARE");
        set.add("JOURNAL OF INTERNATIONAL MEDICAL RESEARCH");
        set.add("FRONTIERS IN MEDICINE");
        set.add("MOL MED REP");
        set.add("ANN PALLIAT MED");
        set.add("101602269");
        set.add("101585484");
        set.add("101515487");
        set.add("HEALTHCARE BASEL");
        set.add("FRONT MOL BIOSCI");
        set.add("CANCER CELL INT");
        set.add("J MATH UK");
        set.add("CANCER MANAG RES");
        set.add("JOURNAL OF CANCER");
        set.add("WORLD JOURNAL OF CLINICAL CASES");
        set.add("ANN PALLLIAT MED");
        set.add("101512700");
        set.add("MITOCHONDRIAL DNA PART B RESOUR");
        set.add("JOURNAL OF PERSONALIZED MEDICINE");
        set.add("101514322");
        set.add("ADV CIV ENG");
        set.add("INTERNATIONAL JOURNAL OF GENERAL MEDICINE");
        set.add("101691304");
        set.add("BIOLOGY BASEL");
        set.add("9878794");
        set.add("101630250");
        set.add("101508617");
        set.add("CANCER CELL INTERNATIONAL");
        set.add("ONCOTARGETS AND THERAPY");
        set.add("101139795");
        set.add("VACCINES BASEL");
        set.add("0370711");
        set.add("101581621");
        set.add("FRONT MED");
        set.add("EXP MOL PATHOL");
        set.add("DIAGNOSTICS");
        set.add("MOLECULAR THERAPY NUCLEIC ACIDS");
        set.add("CANCER MANAGEMENT AND RESEARCH");
        set.add("101083777");
        set.add("MICROPROCESS MICROSY");
        set.add("MED SCI MONITOR");
        set.add("SCIENTIFIC PROGRAMMING");
        set.add("101648047");
        set.add("MICROPROCESSORS AND MICROSYSTEMS");
        set.add("DISCRETE DYN NAT SOC");
        set.add("MEDICAL SCIENCE MONITOR");
        set.add("ADVANCES IN CIVIL ENGINEERING");
        set.add("8807441");
        set.add("101653173");
        set.add("MOLECULAR MEDICINE REPORTS");
        set.add("101580444");
        set.add("101618806");
        set.add("MITOCHONDRIAL DNA B");
        set.add("FRONTIERS IN MOLECULAR BIOSCIENCES");
        set.add("101666525");
        set.add("BIOMEDICINES");
        set.add("101587988");
        set.add("DISCRETE DYNAMICS IN NATURE AND SOCIETY");
        set.add("9800766");
        set.add("LIFE BASEL");
        set.add("J INT MED RES");
        set.add("J CANCER");
        set.add("J CELL MOL MED");
        return set;
    }

    public static Set<String> getEarly2020() {
        Set<String> set = new HashSet<>();
        set.add("101531947");
        set.add("9717360");
        set.add("EXP THER MED");
        set.add("INT J ENERG RES");
        set.add("ONCOL RES");
        set.add("J CLIN MED");
        set.add("BIOSCI REP");
        set.add("101776982");
        set.add("ARTIF CELL NANOMED B");
        set.add("INTERNATIONAL JOURNAL OF ENVIRONMENTAL RESEARCH AND PUBLIC HEALTH");
        set.add("101599172");
        set.add("CATALYSTS");
        set.add("WATER");
        set.add("0375521");
        set.add("101580302");
        set.add("101555929");
        set.add("ATMOSPHERE");
        set.add("101670234");
        set.add("AMERICAN JOURNAL OF TRANSLATIONAL RESEARCH");
        set.add("101088195");
        set.add("101695672");
        set.add("8205768");
        set.add("ONCOLOGY REPORTS");
        set.add("MATHEMATICAL PROBLEMS IN ENGINEERING");
        set.add("J CELL BIOCHEM");
        set.add("0346411");
        set.add("J BIOMATER TISS ENG");
        set.add("101475259");
        set.add("ONCOLOGY RESEARCH");
        set.add("9422756");
        set.add("8102797");
        set.add("ZEITSCHRIFT FUR KRISTALLOGRAPHIE NEW CRYSTAL STRUCTURES");
        set.add("MINERALS BASEL");
        set.add("INTERNATIONAL JOURNAL OF CLINICAL AND EXPERIMENTAL PATHOLOGY");
        set.add("BRAZILIAN JOURNAL OF MEDICAL AND BIOLOGICAL RESEARCH");
        set.add("COATINGS");
        set.add("BIOFACTORS");
        set.add("101204366");
        set.add("JOURNAL OF INTERNATIONAL MEDICAL RESEARCH");
        set.add("MOL MED REP");
        set.add("101546871");
        set.add("Z KRIST NEW CRYST ST");
        set.add("INTERNATIONAL JOURNAL OF ENERGY RESEARCH");
        set.add("101606588");
        set.add("ACTA MEDICA MEDITERR");
        set.add("INT J ENV RES PUB HE");
        set.add("EUR REV MED PHARMACOL SCI");
        set.add("INT J CLIN EXP PATHO");
        set.add("APPL SCI BASEL");
        set.add("ADV DIFFER EQU NY");
        set.add("CANCER BIOMARK");
        set.add("101664675");
        set.add("101600173");
        set.add("101739125");
        set.add("101514322");
        set.add("ADV CIV ENG");
        set.add("ACTA MEDICA MEDITERRANEA");
        set.add("ELECTRONICS");
        set.add("ADVANCES IN DIFFERENCE EQUATIONS");
        set.add("AMERICAN JOURNAL OF CANCER RESEARCH");
        set.add("POLYMERS BASEL");
        set.add("BRAZ J MED BIOL RES");
        set.add("SUSTAINABILITY BASEL");
        set.add("ONCOTARGETS AND THERAPY");
        set.add("101167924");
        set.add("EXPERIMENTAL AND THERAPEUTIC MEDICINE");
        set.add("101493030");
        set.add("J NANOSCI NANOTECHNO");
        set.add("INT J ELECTROCHEM SCI");
        set.add("101671521");
        set.add("BIOMED RES INT");
        set.add("101594777");
        set.add("MATERIALS");
        set.add("101721978");
        set.add("JOURNAL OF NANOSCIENCE AND NANOTECHNOLOGY");
        set.add("JOURNAL OF CELLULAR BIOCHEMISTRY");
        set.add("JOURNAL OF BIOMATERIALS AND TISSUE ENGINEERING");
        set.add("MATHEMATICS BASEL");
        set.add("8213295");
        set.add("MEDICINE");
        set.add("101471010");
        set.add("AM J TRANSL RES");
        set.add("BIOSCIENCE REPORTS");
        set.add("MEDICAL SCIENCE MONITOR");
        set.add("ADVANCES IN CIVIL ENGINEERING");
        set.add("101653204");
        set.add("CELLS");
        set.add("101579976");
        set.add("JOURNAL OF CELLULAR PHYSIOLOGY");
        set.add("101531236");
        set.add("101697598");
        set.add("J INT MED RES");
        set.add("101748883");
        set.add("WATER SUI");
        set.add("INT J CLIN EXP PATHOL");
        set.add("LIFE SCIENCES");
        set.add("BIOMED RESEARCH INTERNATIONAL");
        set.add("EUROPEAN REVIEW FOR MEDICAL AND PHARMACOLOGICAL SCIENCES");
        set.add("101591609");
        set.add("SENSORS");
        set.add("PLANTS BASEL");
        set.add("ELECTRONICS SWITZ");
        set.add("METALS");
        set.add("ADV DIFFER EQU");
        set.add("101596181");
        set.add("LIFE SCI");
        set.add("ENERGIES");
        set.add("ATMOSPHERE BASEL");
        set.add("APPLIED SCIENCES BASEL");
        set.add("BOUNDARY VALUE PROBLEMS");
        set.add("DESALIN WATER TREAT");
        set.add("ARTIFICIAL CELLS NANOMEDICINE AND BIOTECHNOLOGY");
        set.add("INTERNATIONAL JOURNAL OF ELECTROCHEMICAL SCIENCE");
        set.add("AGING US");
        set.add("J CELL PHYSIOL");
        set.add("101480565");
        set.add("Z KRIST NEW CRYST STRUCT");
        set.add("9888589");
        set.add("DESALINATION AND WATER TREATMENT");
        set.add("8911335");
        set.add("BOUND VALUE PROBL");
        set.add("101630280");
        set.add("JOURNAL OF INEQUALITIES AND APPLICATIONS");
        set.add("ONCOL LETT");
        set.add("METALS BASEL");
        set.add("101238455");
        set.add("ONCOTARGETS THER");
        set.add("EXPERIMENTAL AND MOLECULAR PATHOLOGY");
        set.add("COMPLEXITY");
        set.add("ONCOLOGY LETTERS");
        set.add("9609063");
        set.add("0050222");
        set.add("EUR REV MED PHARMACO");
        set.add("101613952");
        set.add("INT J ELECTROCHEM SC");
        set.add("INTERNATIONAL JOURNAL OF MOLECULAR MEDICINE");
        set.add("AM J CANCER RES");
        set.add("INT J ENVIRON RES PUBLIC HEALTH");
        set.add("INT J MOL MED");
        set.add("POLYMERS");
        set.add("100964009");
        set.add("ARTIF CELL NANOMED BIOTECHNOL");
        set.add("101633495");
        set.add("101256509");
        set.add("101682385");
        set.add("101666579");
        set.add("101562250");
        set.add("BIOMED PHARMACOTHER");
        set.add("MOLECULES");
        set.add("J BIOMATER TISSUE ENG");
        set.add("INT J ENERGY RES");
        set.add("101545357");
        set.add("INTERNATIONAL JOURNAL OF CLINICAL AND EXPERIMENTAL MEDICINE");
        set.add("9208097");
        set.add("INT J CLIN EXP MED");
        set.add("101508617");
        set.add("MINERALS");
        set.add("SUSTAINABILITY");
        set.add("MATH PROBL ENG");
        set.add("2985248R");
        set.add("101639462");
        set.add("0370711");
        set.add("NATURAL PRODUCT RESEARCH");
        set.add("EXP MOL PATHOL");
        set.add("9810955");
        set.add("101766564");
        set.add("8112917");
        set.add("J NANOSCI NANOTECHNOL");
        set.add("MATHEMATICS");
        set.add("MEDICINE (BALTIMORE)");
        set.add("INTERNATIONAL JOURNAL OF IMMUNOPATHOLOGY AND PHARMACOLOGY");
        set.add("MED SCI MONITOR");
        set.add("JOURNAL OF CLINICAL MEDICINE");
        set.add("BRAZILIAN J MED BIOL RES");
        set.add("8807441");
        set.add("MOLECULAR MEDICINE REPORTS");
        set.add("CANCER BIOMARKERS");
        set.add("J INEQUAL APPL");
        set.add("NAT PROD RES");
        set.add("SYMMETRY BASEL");
        set.add("PROCESSES");
        set.add("INT J IMMUNOPATH PH");
        set.add("INT J IMMUNOPATHOL PHARMACOL");
        set.add("SENSORS BASEL");
        set.add("IEEE ACCESS");
        set.add("AGRONOMY BASEL");
        set.add("BIOMEDICINE & PHARMACOTHERAPY");
        set.add("ONCOL REP");
        set.add("101549944");
        set.add("101769288");
        set.add("BIOSCIENCE REP");
        set.add("CELLS BASEL");
        return set;
    }

    public static int isEarlyYear(String nlmId, String nlmAbb, String wosFull, String wosJ9, Set<String> set) {
//        Set<String> set = getEarly2024();
        if (set.contains(nlmAbb.toUpperCase().replace(".", " ").replace("-", " ").replace("  ", " ").trim())) {
            return 1;
        } else if (set.contains(wosFull.toUpperCase().replace(".", " ").replace("-", " ").replace("  ", " ").trim())) {
            return 1;
        } else if (set.contains(wosJ9.toUpperCase().replace(".", " ").replace("-", " ").replace("  ", " ").trim())) {
            return 1;
        } else if (set.contains(nlmId.toUpperCase().replace(".", "").replace("-", " ").replace(" ", "").trim())) {
            return 1;
        }
        return 0;
    }

    public static String getFieldStr(String field, Entity entry) {
        String str = entry.getStr(field);
        return null == str ? "" : str;
    }

    public static int getFieldInt(String field, Entity entry) {
        Integer anInt = entry.getInt(field);
        return null == anInt ? 0 : anInt;
    }

    public static List<String> getFieldList(String field, Entity entry) {
        String str = entry.getStr(field);
        if (null != str && str.contains("\"]")) {
            return JSONObject.parseArray(str, String.class);
        }
        return new ArrayList<>();
    }

    public static int isEarlyWarningJournal2024(String nlmId, String nlmAbb, String wosFull, String wosJ9) {
        Set<String> set = getEarly2024();
        if (set.contains(nlmAbb.toUpperCase().replace(".", " ").replace("-", " ").replace("  ", " ").trim())) {
            return 1;
        } else if (set.contains(wosFull.toUpperCase().replace(".", " ").replace("-", " ").replace("  ", " ").trim())) {
            return 1;
        } else if (set.contains(wosJ9.toUpperCase().replace(".", " ").replace("-", " ").replace("  ", " ").trim())) {
            return 1;
        } else if (set.contains(nlmId.toUpperCase().replace(".", "").replace("-", " ").replace(" ", "").trim())) {
            return 1;
        }
        return 0;
    }

    public static Set<String> getEarly2024() {
        Set<String> set = new HashSet<>();
        set.add("ENVIRON SCI POLLUT R");
        set.add("EXP THER MED");
        set.add("J CLIN MED");
        set.add("FRONTIERS IN ENERGY RESEARCH");
        set.add("JOURNAL OF PERSONALIZED MEDICINE");
        set.add("J BIOMATER TISSUE ENG");
        set.add("JOURNAL OF NANOELECTRONICS AND OPTOELECTRONICS");
        set.add("MULTIMED TOOLS APPL");
        set.add("PSYCHIATRIA DANUBINA");
        set.add("FUEL");
        set.add("SCIENCE OF ADVANCED MATERIALS");
        set.add("J SENS");
        set.add("MATH BIOSCI ENG");
        set.add("RADIOLOGIA MEDICA");
        set.add("EXPERIMENTAL AND THERAPEUTIC MEDICINE");
        set.add("MATER EXPRESS");
        set.add("CONNECT SCI");
        set.add("MULTIMEDIA TOOLS AND APPLICATIONS");
        set.add("RADIOL MED");
        set.add("DIAGNOSTICS");
        set.add("MATERIALS EXPRESS");
        set.add("J SENSORS");
        set.add("JOURNAL OF BIOMEDICAL NANOTECHNOLOGY");
        set.add("CONNECTION SCIENCE");
        set.add("CANCERS");
        set.add("FRONT ENERGY RES");
        set.add("ALTERNATIVE THERAPIES IN HEALTH AND MEDICINE");
        set.add("J BIOMATER TISS ENG");
        set.add("JOURNAL OF BIOMATERIALS AND TISSUE ENGINEERING");
        set.add("J NANOELECTRON OPTOELECTRON");
        set.add("PSYCHIATR DANUB");
        set.add("J NANOELECTRON OPTOE");
        set.add("CMES COMP MODEL ENG");
        set.add("ALTERN THER HEALTH M");
        set.add("CMES COMPUTER MODELING IN ENGINEERING & SCIENCES");
        set.add("J BIOBASED MATER BIOENERGY");
        set.add("JOURNAL OF CLINICAL MEDICINE");
        set.add("TROPICAL JOURNAL OF PHARMACEUTICAL RESEARCH");
        set.add("J PERS MED");
        set.add("PSYCHIAT DANUB");
        set.add("ENVIRONMENTAL SCIENCE AND POLLUTION RESEARCH");
        set.add("TROP J PHARM RES");
        set.add("ENVIRON SCI POLLUT RES");
        set.add("SCI ADV MATER");
        set.add("J BIOMED NANOTECHNOL");
        set.add("MATHEMATICAL BIOSCIENCES AND ENGINEERING");
        set.add("JOURNAL OF SENSORS");
        set.add("J BIOBASED MATER BIO");
        set.add("JOURNAL OF BIOBASED MATERIALS AND BIOENERGY");
        set.add("ALTERN THER HEALTH MED");
        set.add("CMES COMP MODEL ENG SCI");
        set.add("BIOENGINEERED");
        set.add("101526829");
        set.add("101658402");
        set.add("9441769");
        set.add("101556828");
        set.add("101606588");
        set.add("101602269");
        set.add("0177625");
        set.add("101581063");
        set.add("9012163");
        set.add("101555932");
        set.add("9424753");
        set.add("101291525");
        set.add("101591609");
        set.add("101230869");
        set.add("101703746");
        set.add("101598992");
        set.add("9502013");
        set.add("101511516");
        set.add("101531947");
        set.add("101638683");
        set.add("101197794");
        set.add("101214391");
        return set;
    }


    // 判断是否为六大刊，若是返回1，此方法与期刊唯一JID不同，只针对期刊名称进行判定。
    public static int is6DaJournals(String nlmId, String nlmAbb, String wosFull, String wosJ9) {
        nlmId = null == nlmId ? "" : nlmId.trim().toUpperCase();
        nlmAbb = null == nlmAbb ? "" : nlmAbb.trim().toUpperCase();
        wosFull = null == wosFull ? "" : wosFull.trim().toUpperCase();
        wosJ9 = null == wosJ9 ? "" : wosJ9.trim().toUpperCase();
        if ("0255562".equals(nlmId) || "2985213R".equals(nlmId) || "7501160".equals(nlmId) || "0413066".equals(nlmId) || "0410462".equals(nlmId) || "0404511".equals(nlmId)) {
            return 1;
        } else if ("N ENGL J MED".equals(nlmAbb) || "LANCET".equals(nlmAbb) || "JAMA".equals(nlmAbb) || "CELL".equals(nlmAbb) || "NATURE".equals(nlmAbb) || "SCIENCE".equals(nlmAbb)) {
            return 1;
        } else if ("NEW ENGLAND JOURNAL OF MEDICINE".equals(wosFull) || "LANCET".equals(wosFull) || "JAMA-JOURNAL OF THE AMERICAN MEDICAL ASSOCIATION".equals(wosFull) || "CELL".equals(wosFull) || "NATURE".equals(wosFull) || "SCIENCE".equals(wosFull)) {
            return 1;
        } else if ("NEW ENGL J MED".equals(wosJ9) || "LANCET".equals(wosJ9) || "JAMA-J AM MED ASSOC".equals(wosJ9) || "CELL".equals(wosJ9) || "NATURE".equals(wosJ9) || "SCIENCE".equals(wosJ9)) {
            return 1;
        }
        return 0;
    }

    public static String printMemoryStr() {
        try {
            String freeMemory = Runtime.getRuntime().freeMemory() / 1024 / 1024 / 1024 + " Gb";
            String totalMemory = Runtime.getRuntime().totalMemory() / 1024 / 1024 / 1024 + " Gb";
            String maxMemory = Runtime.getRuntime().maxMemory() / 1024 / 1024 / 1024 + " Gb";
            return " 内存申请：" + maxMemory + " 空余：" + freeMemory + " 获取：" + totalMemory;
        } catch (Exception e) {
            return "";
        }
    }

    public static double getFieldDouble(String field, Entity entry) {
        Double aDouble = entry.getDouble(field);
        return null == aDouble ? 0.0 : aDouble;
    }

    public static Set<List<String>> getFieldSet(String field, Entity entry) {
        String str = entry.getStr(field);
        Set<List<String>> set = new HashSet<>();
        if (null != str && str.contains("\"]]")) {
            List<String> lists = JSONObject.parseArray(str, String.class);
            for (String s : lists) {
                if (null != s && s.contains("\"]")) {
                    List<String> list = JSONObject.parseArray(s, String.class);
                    set.add(list);
                }
            }
        }
        return set;
    }

    public static boolean isAllDaXie(String str) {
        return str.replaceAll("[A-Z/ ]+", "").isEmpty();
    }


    public static String findPathToFileName(String path) {
        if (StringUtil.isNull(path)) {
            return "";
        } else {
            String[] split = path.split("/");
            System.out.println(split[split.length - 1]);
            return split[split.length - 1];
        }
    }

    public static String filterHtml(String str) {
        Pattern pattern = Pattern.compile(regxpForHtml);
        Matcher matcher = pattern.matcher(str);
        StringBuffer sb = new StringBuffer();
        boolean result1 = matcher.find();
        while (result1) {
            matcher.appendReplacement(sb, "");
            result1 = matcher.find();
        }
        matcher.appendTail(sb);
        return sb.toString();
    }

    public static String filterHtml2(String str) {
        Pattern pattern = Pattern.compile(regxpForHtml2);
        Matcher matcher = pattern.matcher(str);
        StringBuffer sb = new StringBuffer();
        boolean result1 = matcher.find();
        while (result1) {
            matcher.appendReplacement(sb, "/");
            result1 = matcher.find();
        }
        matcher.appendTail(sb);
        return sb.toString();
    }

    /**
     * 判断字符串是否为空
     */
    public static boolean isNotEmpty(String str) {
        if (str != null && !str.equals("") && !str.equals("null") && !str.equals("[]") && !str.trim().equals("")) {
            return true;
        } else {
            return false;
        }
    }

    /**
     * 字符转特定类
     */
//    public static <T> List<T> convertUnite(String str, Class<T> tClass) {
//        List<String> strings = Arrays.asList(str.split(","));
//        List<T> tList = null;
//        try {
//            tList = new ArrayList<>();
//            for (Object list : strings) {
//                T t = tClass.newInstance();
//                BeanUtils.copyProperties(list, t);
//                tList.add(t);
//            }
//        } catch (InstantiationException e) {
////            e.printStackTrace();
//        } catch (IllegalAccessException e) {
////            e.printStackTrace();
//        } catch (Exception e) {
////            e.printStackTrace();
//        }
////        System.out.println("返回list+"+tList);
//        return tList;
//    }

    // 泛型方法，输入是任意类型的集合和目标类型，返回值是目标类型的集合
//    public static <T, R> List<R> convertCollection(String str, Class<R> targetClass) {
//        List<String> strings = Arrays.asList(str.split(","));
//        List<R> targetList = new ArrayList<>();
//        for (String item : strings) {
//            // 这里假设所有源集合的元素都可以通过targetClass的构造函数转化为目标类型
//            // 实际情况可能需要根据具体业务逻辑进行类型转换
//            if (targetClass.isInstance(item)) {
//                targetList.add(targetClass.cast(item));
//            } else {
//                throw new IllegalArgumentException("无法将源集合中的元素转换为目标类型");
//            }
//        }
//        return targetList;
//    }

    /**
     * 判断字符串是否为空
     */
    public static boolean isNotEmpty(Object str) {
        if (str != null && !str.equals("") && !str.equals("null") && !str.equals("[]") && !str.toString().trim().equals("") && !str.toString().trim().equals("[]")) {
            return true;
        } else {
            return false;
        }
    }

    /**
     * 判断字符串是否为空
     */
    public static boolean isEmpty(Object str) {
        if (str == null || str.equals("") && str.equals("null") && str.toString().trim().equals("")) {
            return true;
        } else {
            return false;
        }
    }

    /**
     * 判断对象是否不为空
     */
    public static boolean isNotNull(Object str) {
        if (str != null && !str.equals("") && !str.equals("null") && !str.equals("[]") && !str.toString().trim().equals("") && !str.toString().trim().equals("[]")) {
            return true;
        } else {
            return false;
        }
    }


    /**
     * 判断对象是否为空
     */
    public static boolean isNull(Object str) {
        if (str == null || str.equals("") || str.equals("null") || str.toString().trim().equals("")) {
            return true;
        } else {
            return false;
        }
    }

    public static String encodeUrl(String str) {
        String strEnc = "";
        try {
            strEnc = URLEncoder.encode(str, "utf-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return strEnc;
    }

    public static String decodeUrl(String str) {
        String strDec = "";
        try {
            strDec = URLDecoder.decode(str, "utf-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return strDec;
    }

    public static String removeNonAlphanumeric(String word) {
        // 正则表达式匹配非字母和数字的字符
        String regex = "[^a-zA-Z0-9]";
        // 使用replaceAll方法将非字母和数字的字符替换为空字符串
        String result = word.replaceAll(regex, "");
        return result;
    }
}
